home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
17 Bit Software 6: Level 6
/
17 Bit - Level 6 (1998)(Epic Marketing)[!].iso
/
quartz
/
q0833.dms
/
q0833.adf
/
CalenderMacros
/
calendar.fw3
< prev
next >
Wrap
Text File
|
1997-04-10
|
13KB
|
371 lines
/* Calendar macro for FinalWriter (SoftWood)
Written by Andrew McCardie
amethyst@gulf.net
January 31st, 1995
$VER: FW Calendar Macro v1.1 for FW3
Because of changes in measurement of text blocks in FW3, this macro
will probably not work under previous versions of FW.
This macro can create three different types of calendars: Portrait,
double-portrait, and landscape. It supports all years that are
supported by the Amiga's internal calendar (1978 ->)
Portrait produces a standard 8.5x11 page with a single calendar.
Double portrait produces a standard 8.5x11 page with two calendars.
Landscape produces a standard 11x8.5 page with a single calendar.
While it should handle leap-years, this feature has not been
exhaustively tested. The fonts and margins are designed to be
user-customizeable. Certain default values (in inches) have been
hardcoded into the variables 'top_margin', 'bottom_margin', and
'side_margin' to produce the largest calendars on my DeskJet. You
can change these if you need a smaller calendar or if the calendars
print incorrectly on your setup.
If you change the default fonts, you may have to experiment with their
sizes and widths to get an appropriate look.
If you find any bugs, let me know and I'll try to rectify them.
Disclaimer: I take no responsibility for problems that may result from using
this macro.
*/
OPTIONS RESULTS
ADDRESS "FINALW.1"
ClearDoc FORCE
View 25 /* Speeds things up slightly on fast machines, probably more on
slower machines.
*/
SetMeasure MicroPoints
BoxPrefs LINEWT 2 LINECOLOR Black FILL Solid FILLCOLOR Cyan TEXTFLOW None
TextBlockPrefs TEXTFLOW None
micropoints_per_inch = 720
ShowMessage 1 0 '"What type of calendar?" "" "" "Portrait" "Double-Portrait" "Landscape"'
calendar_type = RESULT
Select
/* Portrait calendar */
When calendar_type = 1 Then
Do
PageSetup PAGETYPE USLetter ORIENT Tall
GetPageSetup WIDTH HEIGHT
Parse Var RESULT true_width true_height
/* The following measurements are based on inches converted to micropoints
Experiment with the defaults at your own risk, however. :) */
side_margin = Trunc(.5 * micropoints_per_inch)
top_margin = Trunc(.625 * micropoints_per_inch)
bottom_margin = Trunc(.625 * micropoints_per_inch)
pagewidth = Trunc(true_width - 2 * side_margin)
pageheight = Trunc(true_height - top_margin - bottom_margin)
text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
box_width = Trunc(pagewidth/7)
box_height = Trunc((pageheight-text_area)/5)
bevel_control = "BEVEL"
SectionSetup TOP top_margin INSIDE side_margin OUTSIDE side_margin
/* Set up font defaults */
datestring_font = "Dragon_BoldItalic"
datestring_font_size = 64
datestring_font_width = 100
text_font = "Dragon_BoldItalic"
text_font_size = 20
text_font_width = 80
day_font = "Dragon_Bold"
day_font_size = 20
day_font_width = 100
iteration = 1
End
/* Double-portrait calendar */
When calendar_type == 2 Then
Do
PageSetup PAGETYPE USLetter ORIENT Tall
GetPageSetup WIDTH HEIGHT
Parse Var RESULT true_width true_height
/* The following measurements are based on inches converted to micropoints
Experiment with the defaults at your own risk, however. :) */
side_margin = Trunc(.5 * micropoints_per_inch)
top_margin = Trunc(.625 * micropoints_per_inch)
bottom_margin = Trunc(5.50 * micropoints_per_inch)
pagewidth = Trunc(true_width - 2 * side_margin)
pageheight = Trunc(true_height - top_margin - bottom_margin)
text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
box_width = Trunc(pagewidth/7)
box_height = Trunc((pageheight-text_area)/5)
bevel_control = "BEVEL"
SectionSetup TOP top_margin INSIDE side_margin OUTSIDE side_margin
/* Set up font defaults */
datestring_font = "Dragon_BoldItalic"
datestring_font_size = 29
datestring_font_width = 150
text_font = "Dragon_BoldItalic"
text_font_size = 18
text_font_width = 80
day_font = "Dragon_Bold"
day_font_size = 20
day_font_width = 100
iteration = 2
End
/* Landscape calendar */
When calendar_type == 3 Then
Do
PageSetup PAGETYPE USLetter ORIENT Wide
GetPageSetup WIDTH HEIGHT
Parse Var RESULT true_width true_height
/* The following measurements are based on inches converted to micropoints
Experiment with the defaults at your own risk, however. :) */
side_margin = Trunc(.5 * micropoints_per_inch)
top_margin = Trunc(.625 * micropoints_per_inch)
bottom_margin = Trunc(.625 * micropoints_per_inch)
pagewidth = Trunc(true_width - 2 * side_margin)
pageheight = Trunc(true_height - top_margin - bottom_margin)
text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
box_width = Trunc(pagewidth/7)
box_height = Trunc((pageheight-text_area)/5)
bevel_control = "BEVEL"
SectionSetup TOP top_margin INSIDE side_margin OUTSIDE side_margin
/* Set up font defaults */
datestring_font = "Montreal_BoldItalic"
datestring_font_size = 44
datestring_font_width = 150
text_font = "Montreal_BoldItalic"
text_font_size = 22
text_font_width = 80
day_font = "Montreal_Bold"
day_font_size = 20
day_font_width = 100
iteration = 1
End
End
current_month = -1
current_month_number = -1
current_year = -1
temp_date = "00000000"
day.6 = 'Saturday'
day.0 = 'Sunday'
day.1 = 'Monday'
day.2 = 'Tuesday'
day.3 = 'Wednesday'
day.4 = 'Thursday'
day.5 = 'Friday'
month.0 = 'January'
month.1 = 'February'
month.2 = 'March'
month.3 = 'April'
month.4 = 'May'
month.5 = 'June'
month.6 = 'July'
month.7 = 'August'
month.8 = 'September'
month.9 = 'October'
month.10 = 'November'
month.11 = 'December'
month_length.0 = 31
month_length.1 = 28
month_length.2 = 31
month_length.3 = 30
month_length.4 = 31
month_length.5 = 30
month_length.6 = 31
month_length.7 = 31
month_length.8 = 30
month_length.9 = 31
month_length.10 = 30
month_length.11 = 31
RequestText '"Month Select" "Month:" 'DATE('M')''
current_month = RESULT
RequestText '"Year Select" "Year:" 'SUBSTR(DATE('S'),1,4)''
current_year = RESULT
if current_year < 1978 then current_year = 1978
Do i = 0 to 11
If current_month = month.i Then current_month_number = i + 1
End
Do While iteration > 0
If current_year//4 == 0 & current_year//100 > 0 Then
month_length.1 = 29
Else
If current_year//400 == 0 Then
month_length.1 = 29
Select
When current_month_number < 10 Then
temp_date = current_year || 0 || current_month_number || "01"
When current_month_number >= 10 Then
temp_date = current_year || current_month_number || "01"
When current_month_number == -1 Then
Exit 10
End
first_day_of_the_month = Date('W', temp_date, 'S')
Select
When first_day_of_the_month == "Saturday" Then cal_start = 6
When first_day_of_the_month == "Sunday" Then cal_start = 0
When first_day_of_the_month == "Monday" Then cal_start = 1
When first_day_of_the_month == "Tuesday" Then cal_start = 2
When first_day_of_the_month == "Wednesday" Then cal_start = 3
When first_day_of_the_month == "Thursday" Then cal_start = 4
When first_day_of_the_month == "Friday" Then cal_start = 5
End
/* Create month/year header */
TextBlockTypePrefs SIZE datestring_font_size WIDTH datestring_font_width FONT datestring_font
datestring = current_month || " " || current_year
obj_top = top_margin + datestring_font_size * 9
DrawTextBlock 1 side_margin obj_top datestring
datestring_obj = RESULT
Redraw
GetObjectCoords datestring_obj
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
text_edge = Trunc(side_margin + (pagewidth - obj_width)/2)
SetObjectCoords datestring_obj Page text_edge obj_top obj_width obj_height
i = 0
Do While (i < 7)
j = 0
box_left = side_margin+box_width*i
box_top = top_margin+text_area
Do While (j < 5)
serial_position = i + (j * 7)
index = current_month_number - 1
If serial_position >= cal_start & serial_position < cal_start+month_length.index
Then BoxPrefs LINEWT 2 LINECOLOR Black FILL Transparent TEXTFLOW None
Else BoxPrefs LINEWT 2 LINECOLOR Black FILL Solid FILLCOLOR Cyan TEXTFLOW None
box_top = top_margin+text_area+box_height*j
text_top = box_top + box_height - day_font_size * 5
DrawBox Page box_left box_top box_width box_height bevel_control
box_obj.i.j = RESULT
day_of_month = serial_position-cal_start+1
TextBlockTypePrefs SIZE day_font_size WIDTH day_font_width FONT day_font
GetBoxPrefs FILL
If RESULT = "Transparent" Then
Do
DrawTextBlock Page box_left text_top day_of_month
day_obj = RESULT
Redraw
GetObjectCoords day_obj
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
text_edge = Trunc(box_left + (box_width - obj_width - 50))
SetObjectCoords day_obj Page text_edge text_top obj_width obj_height
End
j = j + 1
End
i = i + 1
End
i = 0
Do While (i < 7)
GetObjectCoords box_obj.i.0
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
box_center = Trunc(obj_left + obj_width/2)
box_top = obj_top
TextBlockTypePrefs SIZE text_font_size WIDTH text_font_width FONT text_font
DrawTextBlock 1 obj_left obj_top day.i
text_obj.i = RESULT
Redraw
GetObjectCoords text_obj.i
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
text_edge = Trunc(box_center - obj_width/2)
text_bottom = box_top-text_font_size*5
SetObjectCoords text_obj.i Page text_edge text_bottom obj_width obj_height
i = i + 1
End
/* Special cases for months whose last day(s) wrap to the
beginning of the week */
If cal_start+month_length.index == 36 Then
Do
TextBlockTypePrefs SIZE day_font_size WIDTH day_font_width FONT day_font
day_of_month = day_of_month + 1
GetObjectCoords box_obj.0.4
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
DrawLine Page obj_left+40 obj_top+obj_height-40 obj_left+obj_width-40 obj_top+40
DrawTextBlock 1 obj_left+50 obj_top+day_font_size*12 day_of_month
End
If cal_start+month_length.index == 37 Then
Do
TextBlockTypePrefs SIZE day_font_size WIDTH day_font_width FONT day_font
day_of_month = day_of_month + 1
GetObjectCoords box_obj.0.4
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
DrawLine Page obj_left+40 obj_top+obj_height-40 obj_left+obj_width-40 obj_top+40
DrawTextBlock 1 obj_left+50 obj_top+day_font_size*12 day_of_month
day_of_month = day_of_month + 1
GetObjectCoords box_obj.1.4
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
DrawLine Page obj_left+40 obj_top+obj_height-40 obj_left+obj_width-40 obj_top+40
DrawTextBlock 1 obj_left+50 obj_top+day_font_size*12 day_of_month
End
/* Handles special case of double portrait calendar */
If iteration == 2 Then
Do
drop datestring
top_margin = Trunc(5.5 * micropoints_per_inch)
bottom_margin = Trunc(.625 * micropoints_per_inch)
pagewidth = Trunc(true_width - 2 * side_margin)
pageheight = Trunc(true_height - top_margin - bottom_margin)
text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
box_width = Trunc(pagewidth/7)
box_height = Trunc((pageheight-text_area)/5)
If current_month_number < 12 Then
Do
current_month = month.current_month_number
current_month_number = current_month_number + 1
End
Else
Do
current_month_number = 1
current_month = "January"
current_year = current_year + 1
End
End
iteration = iteration - 1
End
SectionSetup BOTTOM bottom_margin
SelectObject
Redraw
View 50